<template>
    <el-dialog title="批量添加传感器" :visible.sync="isAddShow" :close-on-click-modal="false">
        <el-form ref="addSensorForm">
            <el-form-item label="添加传感器" label-width="120">
                <el-input-number v-model="SensorStart" label="最小号"></el-input-number> 号传感器 ~
                <el-input-number v-model="SensorEnd" label="最大号"></el-input-number> 号传感器
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="isAddHidden()">取 消</el-button>
            <el-button type="primary" @click="AddAction">确 定</el-button>
        </div>
    </el-dialog>
</template>
<script>
export default {
  name: "addSensorShow",
  props: {
    isAddShow: Boolean,
    AddSensorStart: Number,
    AddSensorEnd: Number
  },

  data() {
    return {
      SensorStart: 0,
      SensorEnd: 0
    };
  },
  watch: {
    SensorStart: {
      handler(newVal) {
        if (newVal > this.SensorEnd) {
          this.SensorEnd = this.SensorStart;
        }
      }
    },
    SensorEnd: {
      handler(newVal) {
        if (newVal < this.SensorStart) {
          this.SensorStart = this.SensorEnd;
        }
      }
    }
  },
  methods: {
    AddAction() {
      this.$emit("update:AddSensorStart", this.SensorStart);
      this.$emit("update:AddSensorEnd", this.SensorEnd);
      this.$emit("AddAction");
    },
    isAddHidden() {
      this.$emit("isAddShow", false);
    }
  }
};
</script>
